#ifndef BSP_H
#define BSP_H
#include "BF7006AMxx.h"

#define R1 200000.0
#define R2 22000.0
#define R3 82000.0
#define R4 22000.0
#define PWM_VCC 5.0   //PWM VCC 5V


#define BLUE_LED_GPIO  	    GPIOF
#define BLUE_LED_PIN   	    GPIO_PIN_5
#define GREEN_LED_GPIO  	GPIOF
#define GREEN_LED_PIN   	GPIO_PIN_6

#define VCC_EN_GPIO			GPIOD
#define VCC_EN_PIN			GPIO_PIN_1

#define VCC_9V_GPIO			GPIOG
#define VCC_9V_PIN			GPIO_PIN_5

#define SC8101_EN_GPIO		GPIOD
#define SC8101_EN_PIN		GPIO_PIN_5

#define SC5003_EN_GPIO		GPIOC
#define SC5003_EN_PIN		GPIO_PIN_1

#define SC5003_VDMO_GPIO	GPIOA
#define SC5003_VDMO_PIN		GPIO_PIN_0

typedef enum
{
    SET_VDM_VTH_50MV        = 1,
    SET_VDM_VTH_40MV        = 2,  //defuat
    SET_VDM_VTH_20MV        = 3,
    SET_VDM_VTH_10MV        = 4,

    SET_VTH_HIGH_200MV      = 5,  //defuat
    SET_VTH_HIGH_150MV      = 6,
    SET_VTH_HIGH_100MV      = 7,
    SET_VTH_HIGH_50MV       = 8,

    SET_VTH_LOW_100MV       = 9,  //defuat
    SET_VTH_LOW_75MV        = 10,
    SET_VTH_LOW_50MV        = 11,
    SET_VTH_LOW_25MV        = 12,

    SET_Q_FACTOR_DET_ENABLE     = 13,
    SET_Q_FACTOR_DET_DISABLE    = 14,   //defuat
    SET_VIN_OVLO_ENABLE     = 15,  //defuat
    SET_VIN_OVLO_DISABLE    = 16,

    SET_HIGH_SIDE_LOW_SIDE_DEAD_TIME_20N   = 17,
    SET_HIGH_SIDE_LOW_SIDE_DEAD_TIME_40N   = 18,  //defuat
    SET_HIGH_SIDE_LOW_SIDE_DEAD_TIME_60N   = 19,
    SET_HIGH_SIDE_LOW_SIDE_DEAD_TIME_80N   = 20,

    SET_DRIVER_SPEED_SLOWEST        = 21,
    SET_DRIVER_SPEED_SLOW           = 22,
    SET_DRIVER_SPEED_FAST           = 23,  //defuat
    SET_DRIVER_SPEED_FASTEST        = 24,
    
    SET_R_SENSE_20MOHM              = 25,
    SET_R_SENSE_10MOHM              = 26,  //defuat
    SET_R_SENSE_5MOHM               = 27,

    SET_VDD_VOL_4V6                 = 28,
    SET_VDD_VOL_5V                  = 29,

    SET_OCP_DECREASE_1A             = 30,
    SET_DEFAULT_OCP                 = 31,

    SET_IDM_VTH_4mV                 = 32,
    SET_IDM_VTH_8mV                 = 33,
    SET_IDM_VTH_16mV                = 34,
    SET_IDM_VTH_32mV                = 34,
	SET_IDM_VTH_NUM                 = 35,
}SC5003_SET_TYPE;

extern void bsp_init(void);

/*led*/
extern void blue_led_on(void);
extern void blue_led_off(void);
extern void green_led_on(void);
extern void green_led_off(void);
extern void led_init(void);

/*VCC*/
extern void vcc_enable(FunctionalState enable);
extern void enable_9V(FunctionalState enable);

/* SC8101*/
extern void sc8101_enable(FunctionalState enable);
extern void set_sc8101_vout(float vout);

/* SC5003*/
extern void sc5003_enable(FunctionalState en);
extern void sc5003_config(SC5003_SET_TYPE set);
extern void sc5003_Q_detect_en(void);
extern void sc5003_pwm_enable(FunctionalState en);
extern void sc5003_pwm1_enable(FunctionalState en);
/*coil select*/
extern void coil_select(uint8_t num);

void set_pwm_period(uint16_t mod_count);
#endif
